<?php

use App\Http\Controllers\Auth\PhoneLoginController;
use App\Http\Controllers\AssignmentController;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return redirect()->route('assignments.index');
});

// 手机号登录相关路由
Route::get('login', [PhoneLoginController::class, 'showLoginForm'])->name('phone.login');
Route::post('login', [PhoneLoginController::class, 'login'])->name('login');
Route::post('logout', [PhoneLoginController::class, 'logout'])->name('logout');

// 需要认证的路由
Route::middleware('auth')->group(function () {
    // 作业相关路由
    Route::post('assignments/{assignment}/complete', 'AssignmentController@complete')->name('assignments.complete');
    Route::resource('assignments', 'AssignmentController');
});
